#include <stdlib.h>
#include <stdio.h>

/*打印数组的全排列*/

void myprint (int* p, int curr, int len)
{
    int tmp, m, n;
    for ( m = 0; m < len; m++)
    {
        for (n = 0; n < len; n++)
        {
            if (n + curr < len)
            {
                printf ("%d ", *(p+curr+n));
            }
            else
            {
                printf ("%d ", *(p+curr+n-len));
            }
        }
        curr++;
        printf ("\n");
        //printf ("i is %d, curr is %d \n", i, curr);
    }
    printf ("%d \n", __LINE__);
}

int main ()
{
    int len = 5;
    int a[5] = {1,2,3,4,5};
    int i, j, tmp;
    //printf ("%d \n", __LINE__);
    for (i = 0; i < len; i++)
    {
        for (j = i + 1; j < len; j++)
        {
            myprint (a, 0, len);
            tmp = *(a+j);
            *(a+j) = *(a+i);
            *(a+i) = tmp;
         }
    }
    return 0;
}
